<style lang="less" scoped="scoped">
	@import "./login.less";
</style>

<template>
	<div class="bg">
		<Form class="loginDiv" ref="form" :model="form" :rules="ruleform" label-position="top">
			<img src="../../assets/images/airusheng.png"/>
	        <FormItem label="用户名" prop="name">
	            <Input type="text" prefix="ios-contact" clearable v-model="form.name"></Input>
	        </FormItem>
	        <FormItem label="密码" prop="password">
	            <Input type="password" prefix="ios-lock-outline" clearable v-model="form.password"></Input>
	        </FormItem>
	        <FormItem>
	            <Button type="success" long @click="handleSubmit('form')">立即登录</Button>
	        </FormItem>
	    </Form>
	</div>
</template>

<script>
	export default{
		name:'login',
		data(){
			return{
				form:{
					name:'',
					password:''
				},
				ruleform:{
					name:[
					     {required:true,message:'请输入用户名',trigger:'blur'},
					     { type: 'string',message: '用户名不能为空', trigger: 'blur' }
					],
					password:[
					     {required:true,message:'请输入密码',trigger:'blur'},
					     { type: 'string', min: 6, message: '密码长度不能少于6位', trigger: 'blur' }
					]
				}
			}
		},
		methods:{
			handleSubmit(name){
				this.$refs[name].validate((valid)=>{
					if(valid){
						this.Login(this.form)
					}else{
						this.$Message.error('登录失败!');
					}
				})
			},
			Login(data){
				 this.$router.push({ name: 'zhuye' }) 
//				this.$ajax.post('',data).then(res => {
//				        this.$router.push({ path: '/home' }) 
//				},(err) => {
//					console.log('服务器出错，稍后再试')
//              })
			}
		}
	}
</script>

